﻿using CPF;
using CPF.Animation;
using CPF.Charts;
using CPF.Controls;
using CPF.Drawing;
using CPF.Input;
using CPF.Shapes;
using CPF.Styling;
using CPF.Svg;
using CPFUI.IHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPFUI.IControl
{
    [CPF.Design.DesignerLoadStyle("res://$safeprojectname$/Stylesheet1.css")]//用于设计的时候加载样式
    public class ButtonEx : ButtonBase
    {
        public object Source
        {
            get
            {
                return GetValue<object>();
            }
            set
            {
                SetValue(value);
            }
        }
        [PropertyMetadata(typeof(Color), "#666")]
        public Color BackColor
        {
            get
            {
                return GetValue<Color>();
            }
            set
            {
                SetValue(value);
                this.Triggers.Add(nameof(IsMouseOver), Relation.Me, null, (nameof(Background), value.ColorDepthVariationChange(-0.1f)));
                this.Triggers.Add(nameof(IsPressed), Relation.Me, null, (nameof(Background), value.ColorDepthVariationChange(-0.2f)));
            }
        }
        public ButtonEx()
        {
            Width = 80; Height = 30;
            IsAntiAlias = true;
            this.CornerRadius = "6";
            BorderFill = null;
        }
        //模板定义
        protected override void InitializeComponent()
        {

            Background = BackColor;
            Children.Add(new Border
            {
                Name = "contentPresenter",
                Height = "100%",
                Width = "100%",
                BorderFill = null,
                PresenterFor = this
            });
        }

#if !DesignMode //用户代码写到这里，设计器下不执行，防止设计器出错



        //用户代码

#endif
    }
}
